﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Manager_personnel.account
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
            btnlogin.Click += new EventHandler(btnlogin_Click);
            btnregister.Click += new EventHandler(btnregister_Click);
        }
        #region botton đăng kí
        void btnregister_Click(object sender, EventArgs e)
        {
            register register = new register();
            this.Hide();
            register.ShowDialog();
            this.Show();
        }
        #endregion
        #region login
        void btnlogin_Click(object sender, EventArgs e)
        {
            string username = txtuser.Text;
            string pass = txtpass.Text;

            clsdulieu clsdata = new clsdulieu();
            if (username == "" || pass == "")
            {
                MessageBox.Show("Please check info account");
                txtuser.Focus();
            }
            else
            {
                int count = clsdata.login(username, pass);
                if (count > 0)
                {
                    MessageBox.Show("Chúc mừng bạn đã đăng nhập thành công");
                    Form1 Form1 = new Form1();
                    Form1.Show();
                }
                else
                {
                    MessageBox.Show("Đăng nhập thất bại");
                    txtuser.Text = "";
                    txtpass.Text = "";
                    txtuser.Focus();
                }
               
            }
        }
        #endregion 
    }
}
